package com.easy.controllor;

import com.easy.bean.Station;
import com.easy.bean.User;
import com.easy.service.StationService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/station")
public class StationControllor {

    @Autowired
    StationService stationService;

    @PostMapping
    public Result add(@RequestBody Station station){
        Object obj = stationService.add(station);
        return Result.success(obj);
    }

    @DeleteMapping("/{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj = stationService.del(id);
        return Result.success("删除成功",obj);
    }

    @PutMapping
    public Result edit(@RequestBody Station station){
        Object obj = stationService.edit(station);
        return Result.success("编辑信息成功",obj);
    }

    @GetMapping
    public Result all(@RequestBody Station station){
        Object obj = stationService.all(station);
        return Result.success(obj);
    }

    @GetMapping("/{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj = stationService.one(id);
        return Result.success(obj);
    }

    @GetMapping("/page")
    public Result page(Page page, Station station){
        //查询一共多少条数据
        //查询当前页要显示的数据
        //封装到page里面去
        stationService.page(page,station);
        //返回page对象
        return Result.success(page);
    }




}
